* Apply to:  sfmay_2018.xls
* Description:  Table 1 and Figure A1

clear


import excel "...\2204 JEPS\sfmay_2018.xls", sheet("Sheet1") firstrow


* Table 1. Policy Questions with Candidates' and Citizens' Answers
* Candidate answers coded from publicly available questionnaires

tab pol1_congprice

tab pol2_fbitaskforce

tab pol3_tsfhike

tab pol4_tasers

tab pol6_tenantrep

tab pol7_upzoning

tab pol8_rcv

tab pol9_guardians

tab pol5_charterschool

tab pol10_taxpowers


* Party ID

gen democrat = 0
replace democrat = 1 if party>=5 & party<=7
replace democrat = . if party==.

gen republican = 0
replace republican = 1 if party>=1 & party<=3
replace republican = . if party==.

gen independent = 0
replace independent = 1 if party==4
replace independent = 1 if party==8
replace independent = 1 if party==9
replace independent = . if party==.


* Figure A1. Distribution of Candidate and Citizen Ideal Points

drop if id > 80000


kdensity d1, nograph generate(x fx)
kdensity d1 if democrat==1, nograph generate(fx_democrat) at(x)
kdensity d1 if independent==1, nograph generate(fx_independent) at(x)
kdensity d1 if republican==1, nograph generate(fx_republican) at(x)


twoway line fx_democrat x, lcolor(black) lpattern(dash) lwidth(medthick) || ///
     line fx_independent x, lcolor(black) lpattern(solid) lwidth(medthick) || ///
     line fx_republican x, lcolor(black) lpattern(longdash_dot) lwidth(medthick) ///
	 xlabel(-2(1)3) xtitle(" " "{bf:Ideal Point}") ///
	 ylabel(0(.10).6) ytitle("{bf:Density}" " " ) ///
     text(.57 -1.75 "{bf:Dash = Democrats}", color(black) placement(e) just(left)) ///
     text(.54 -1.75 "{bf:Solid = Independent/Other}", color(black) placement(e) just(left)) ///
     text(.51 -1.75 "{bf:Dash Dot = Republicans}", color(black) placement(e) just(left)) ///
     text(.12 -1.00 "{bf:{subscript:Jane}}", size(vlarge) color(black) placement(w)) ///
     text(.09 -1.00 "{bf:{subscript:Kim}}", size(vlarge) color(black) placement(w)) ///
     text(.06 -1.00 "{bf:{subscript:|}}", size(huge) color(gray)) ///
     text(.03 -1.00 "{bf:{subscript:|}}", size(huge) color(gray)) ///
     text(.16 -.83 "{bf:{subscript:Mark}}", size(vlarge) color(black) placement(e)) ///
     text(.13 -.83 "{bf:{subscript:Leno}}", size(vlarge) color(black) placement(e)) ///
     text(.09 -.71 "{bf:{subscript:|}}", size(huge) color(gray)) ///
     text(.06 -.71 "{bf:{subscript:|}}", size(huge) color(gray)) ///
     text(.03 -.71 "{bf:{subscript:|}}", size(huge) color(gray)) ///
     text(.09 1.05 "{bf:{subscript:London}}", size(vlarge) color(black) placement(w)) ///
     text(.06 1.05 "{bf:{subscript:Breed}}", size(vlarge) color(black) placement(w)) ///
     text(.03 1.00 "{bf:{subscript:|}}", size(huge) color(gray)) ///
     text(.14 1.96 "{bf:{subscript:Richie}}", size(vlarge) color(black) placement(w)) ///
     text(.11 2.11 "{bf:{subscript:Greenberg}}", size(vlarge) color(black) placement(w)) ///
     text(.06 1.86 "{bf:{subscript:|}}", size(huge) color(gray) placement(w)) ///
     text(.03 1.86 "{bf:{subscript:|}}", size(huge) color(gray) placement(w)) ///
     legend(off) plotregion(margin(zero) color(white)) graphregion(color(white))


* Use graph editor to adjust size to to 6.5" width and 3.47" height

* End
